package com.ws.service;

import com.github.pagehelper.PageHelper;
import com.ws.domain.Goods;
import com.ws.domain.Tops;
import com.ws.mapper.TopsDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TopsService {

    @Autowired
    private TopsDao topsDao;

    public void setTopsDao(TopsDao topsDao) {
        this.topsDao = topsDao;
    }

    public Tops getByGoodIdAndType(int goodId, byte type) {
        return topsDao.getByGoodIdAndType(goodId, type);
    }
//    分页查询所有今日推荐商品的ID集合的服务
//public List<Integer>  getGoodIdsByType(byte type) {
//    List<Integer> ids = topsDao.getGoodIdsByType(type);
//    return ids;
//}
public List<Tops> pageTops(byte type,int page, int size){
    PageHelper.startPage(page,size);
    return topsDao.getGoodIdsByType(type);
}

    //加入今日推荐
    public boolean topSave(int goodId, int type) {
        return topsDao.topSave(goodId, type);
    }
    //移除今日推荐
    public boolean topDelete(int goodId, int type) {
        return topsDao.topDelete(goodId, type);
    }


}
